<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>用户数量</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>用户数量统计</legend>
</fieldset>
<!--面板-->
<div class="layui-card">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header"><i class="fa fa-line-chart icon"></i>不同权限用户数量统计</div>
                <div class="layui-card-body">
                    <div id="countByUser" style="width: 100%;min-height:500px"></div>
                </div>
            </div>
        </div>
</div>

<script src="../lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
<script src="../lib/layui-v2.6.3/layui.js"></script>
<script src="../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['layer','miniTab','echarts'],function(){
        var $ = layui.jquery,
            layer = layui.layer,
            miniTab = layui.miniTab,
            echarts = layui.echarts;

        miniTab.listen();

        var countByUser=echarts.init(document.getElementById('countByUser'));

        var option={
            tooltip: {
                trigger: 'axis'
            },
            legend:{
                data:['用户数量']
            },
            toolbox: {
                feature: {
                    saveAsImage: {}
                }
            },
            xAxis: {
                type: 'category',
                data:['主任工程师','负责人','监察员']
            },
            yAxis: {
                type: 'value'  //数值轴
            },
            series:[
                {
                    name:"用户数量",
                    type:'bar',
                    data:[]
                }
            ]
        };

       fetch("/echarts/bar").then(resopnse=>resopnse.json()).then(res=>{
           //柱状图
           console.log(res);
           option.series[0].data=res.data;

           countByUser.setOption(option);
       })
    })
</script>
</body>
</html>